<!--
 * @Author: your name
 * @Date: 2021-09-16 09:39:55
 * @LastEditTime: 2021-09-16 09:46:54
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\6-jQuery\day05\4-绘制图像.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绘制图像</title>
    <script>
        window.onload = function() {
            //1.获取画布
            var canvas = document.querySelector("canvas");
            //2.获取画笔 上下文对象---->context
            var context = canvas.getContext("2d");
            //3.创建img节点
            var img = new Image();
            //4.放图片路径
            img.src = "../day04/test.jpg";
            //5.绘制图片
            img.onload = function() {
                context.drawImage(img, 0, 0, 200, 200);
            }
        }
    </script>
</head>

<body>
    <canvas width="400px" height="400px"></canvas>
</body>

</html>